const state = {
	addGoodsList: [],
};
const actions = {
	addZyGoods({ commit }, valueObj) {
		commit('ADD_ZY_GOODS', valueObj);
	},
	editZyGoods({ commit }, valueObj) {
		commit('EDIT_ZY_GOODS', valueObj);
	},
	delZyGoods({ commit }, params) {
		commit('DEL_ZY_GOODS', params);
	},
	clearZyGoods({ commit }) {
		commit('CLEAR_ZY_GOODS');
	}
};
const mutations = {
	ADD_ZY_GOODS(state, valueObj) {
		state.addGoodsList.push(valueObj);
	},
	EDIT_ZY_GOODS(state, valueObj) {
		const index = state.addGoodsList.findIndex(item => item.id == valueObj.id);
		const arr = [...state.addGoodsList];
		arr[index] = valueObj
		state.addGoodsList = [...arr];
	},
	DEL_ZY_GOODS(state, params) {
		const index = state.addGoodsList.findIndex(item => item.id == params.id);
		state.addGoodsList.splice(index, 1);
	},
	CLEAR_ZY_GOODS(state) {
		state.addGoodsList = [];
	}
};
const getters = {
	addGoodsList: state => state.addGoodsList || [],
};
export default {
	namespaced: true,
	actions,
	mutations,
	state,
	getters,
}